use utils::trie_tree::ScanResult;

mod s2t {
    include!(concat!(env!("OUT_DIR"), "/s2t.rs"));
}
mod t2s {
    include!(concat!(env!("OUT_DIR"), "/t2s.rs"));
}
pub fn converter(input: &str, tp: &str) -> String {
    let trans = match tp {
        "s2t" => &s2t::SIGLETON,
        "t2s" => &t2s::SIGLETON,
        _ => panic!("Unsupported tp: {}", tp),
    };
    let input_chars = input.chars().collect::<Vec<_>>();
    trans
        .iter_scan(&input_chars)
        .filter_map(|r| match r {
            ScanResult::Found(&v) => Some(v.to_string()),
            ScanResult::NotFound(idx) => input_chars.get(idx).map(|c| c.to_string()),
        })
        .collect::<String>()
}
